export default {
  data() {
    return {
      swiperValue: {},//swiper所有信息
      statusBarHeight: 0,
      currentIndex: 0,
      list: [],
      id: 0,
      arr: [],
      xedColorList: [],
      isIcon: false,//删除按钮显示
      show: false,//删除模态框
    }
  },
  onShow(){
    this.currentIndex = 0
    this.getCarBookList()
  },
  filters: {
  	million(value) { //过万处理
  		let num
  		if (value > 9999) { //大于9999显示x.xx万
  			num = ((value / 1000) / 10).toFixed(2) + '万'
  		} else if (value <= 9999 && value >= -9999) {
  			num = value + '元'
  		} else if (value < -9999) { //小于-9999显示-x.xx万
  			num = -((Math.abs(value) / 1000) / 10).toFixed(2) + '万'
  		}
  		return num
  	}
  },
  onLoad() {
    this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight * 2
  },
  methods: {
    lookPz(){
      this.swiperValue = this.list.find(item => item.id === this.id)
      let carList = {
        carid: this.swiperValue.configuration_Id,
        car_Type_Name: this.swiperValue.car_Type_Name,
        configuration_Name: this.swiperValue.configuration_Name,
        car_ImageList: [
          {
            image: 'https://files.yzsheng.com/goodimg/cartypeimg/' + this.swiperValue.car_Type_Id + '.png'
          }
        ],

      }
      uni.navigateTo({
        url: '/pages_common/productDcarConfigs/productDcarConfigs?carsList='+encodeURIComponent(
          JSON.stringify(carList))
      })
    },
    // 删除
    async del(){

      let id = this.id
      let data = {
			  'id': id
      }
      const res = await this.$api.comparison.deleteCarFindPrice(data)

      this.getCarBookList()
      this.isIcon =false
    },
    //录入信息
    gotoInfo(){
      this.swiperValue = this.list.find(item => item.id === this.id)

      let list = JSON.stringify(this.swiperValue)
      if(this.list.length){
        uni.navigateTo({
				  url: '/price_Comparison/input_info/input_info?list='+list
        })
      }else{
        this.$u.toast('请添加车源')
      }

    },
    //编辑
    async edit(){
      this.isIcon = !this.isIcon
    },
    //分割颜色
    filtercolor(data) {
		  data.forEach(item => {
		    var arr = item.inColour.colorCoding.split('/')
		    item.inColour.neiColor = arr
		  })
		  return data
    },
    //获取询比价列表
    async getCarBookList() {
      try {
        let data = {
          'pageIndex': 1,
          'pageSize': 10
        }
        const res = await this.$api.comparison.getCarBookList(data)
        this.list = res.data.list
        // console.log(this.list)
        this.id = this.list[0].id
        // console.log(this.id)
      } catch (e) {

      }
    },
    //添加配置
    addConf() {
      uni.navigateTo({
        url: '/price_Comparison/addYourCar/addYourCar?type=120'+'&pageFrom=addYourCar'
      })
    },
    //轮播定位
    swierChange(e) {

      this.id = e.target.currentItemId
      this.currentIndex = e.detail.current

    },
  }
}
